package com.kelvin.paopao.adapter;

import android.content.Context;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.kelvin.kelvinlib.utils.CommonUtil;
import com.kelvin.paopao.R;

import java.io.File;

/**
 * Created by Administrator on 2017/5/14.
 */

public class PersonPhotoImageAdapter extends BaseQuickAdapter<String, BaseViewHolder> {

    private Context context;

    public PersonPhotoImageAdapter(Context context) {
        super(R.layout.recycler_img_item);
        this.context = context;
    }

    @Override
    protected void convert(BaseViewHolder helper, String item) {
        ImageView iv = helper.getView(R.id.iv);
        if (CommonUtil.isUrlImage(item)) {
            Glide.with(context).load(item).centerCrop().into(iv);
        } else {
            Glide.with(context).load(new File(item)).centerCrop().into(iv);
        }
        helper.addOnClickListener(R.id.iv_delete).addOnClickListener(R.id.iv);
    }
}
